<!-- company表单弹窗 -->
<form id="recruitment-form" lay-filter="recruitment-form" class="layui-form model-form">
    <input name="id" type="hidden"/>

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">公司名字</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input name="companyname" placeholder="请输入名字" type="text" class="layui-input" maxlength="20"-->
<!--                   lay-verify="required" required />-->
<!--        </div>-->
<!--    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">公司名字</label>
        <div class="layui-input-block">
            <select name="companyId" xm-select="companyId" lay-verify="required">
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">需求技术</label>
        <div class="layui-input-block">
            <input name="skills" placeholder="请输入技术" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">招聘人数</label>
        <div class="layui-input-block">
            <input name="employeeCount" placeholder="请输入人数" type="text" class="layui-input" lay-verify="required"
                   required/>
        </div>
    </div>
        <div class="layui-form-item">
            <label class="layui-form-label">工作年限</label>
            <div class="layui-input-block">
                <input name="experience" placeholder="请输入工龄" type="text" class="layui-input" lay-verify="required"
                       required/>
            </div>
        </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工作职责</label>
                <div class="layui-input-block">
                    <input name="tasks" placeholder="请输入职责" type="text" class="layui-input" lay-verify="required"
                           required/>
                </div>
            </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">开始时间</label>
                    <div class="layui-input-block">
                        <input name="startTime" placeholder="请输入开始时间" type="text" class="layui-input" lay-verify="required"
                               required/>
                    </div>
                </div>

    <div class="layui-form-item">
        <label class="layui-form-label">结束时间</label>
        <div class="layui-input-block">
            <input name="endTime" placeholder="请输入结束时间" type="text" class="layui-input" lay-verify="required"
                   required/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">费用</label>
        <div class="layui-input-block">
            <input name="costId" placeholder="请输入费用" type="text" class="layui-input" lay-verify="required"
                   required/>
        </div>
    </div>





<!--    </div>-->
<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">合作</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="radio" name="enabled" value="true" title="冻结" checked/>-->
<!--            <input type="radio" name="enabled" value="false" title="合作"/>-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item model-form-footer">
        <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
        <button class="layui-btn" lay-filter="recruitment-form-submit" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'admin', 'form', 'formSelects'], function () {
        var layer = layui.layer;
        var admin = layui.admin;
        var form = layui.form;
        var formSelects = layui.formSelects;

        form.render('radio');

        // 获取所有角色
            layer.load(2);
            admin.req('api-company/company', {}, function (data) {
                layer.closeAll('loading');
                if (0 == data.code) {
                    // 渲染多选下拉框
                    var roleSelectData = new Array();
                    console.log(data,2222);
                    for (var i = 0; i < data.data.length; i++) {

                        roleSelectData.push({name: data.data[i].companyname, value: data.data[i].id});
                    }
                    formSelects.data('companyId', 'local', {arr: roleSelectData});

                // 回显user数据
                var recruitment = admin.getTempData('t_recruitment');

                $('#recruitment-form').attr('method', 'POST');
                if (recruitment) {
                    form.val('recruitment-form', recruitment);
                    $('#recruitment-form').attr('method', 'POST');
                    var rds = new Array();
                    for (var i = 0; i < recruitment.companyname.length; i++) {
                        rds.push(recruitment.companyname[i].id);
                    }
                    formSelects.value('companyId', rds);
                }

            } else {
            layer.msg('获取角色失败', {icon: 2, time: 500});
        }
    }, 'GET');
    // }
    //         });


        // 表单提交事件
        form.on('submit(recruitment-form-submit)', function (data) {
            console.log(data,11111);
            layer.load(2);
            admin.req('api-company/recruitment/save', JSON.stringify(data.field), function (data) {
                console.log(data,3333);
                layer.closeAll('loading');
                if (data.code == 0) {
                    layer.msg(data.msg, {icon: 1, time: 500});
                    admin.finishPopupCenter();
                } else {
                    layer.msg(data.msg, {icon: 2, time: 500});
                }
            }, $('#recruitment-form').attr('method'));

            return false;
        });
    });
</script>